package com.test.exam.dao;

import java.util.HashMap;
import java.util.List;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.test.exam.commons.PageHelper;
import com.test.exam.domain.Subject;

@Repository
public class SubjectDao {
	private final String SUBJECT_NS = "com.test.exam.mapper.SubjectMapper";
	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;
	
	// 전체 반 row수
		public int getSubjectCount(){
			return sqlSessionTemplate.selectOne(
					SUBJECT_NS+".getSubjectCount");
		}
	
	// 페이지 반 목록
	public List<HashMap> getAllSubjectsByCurrentPage(PageHelper pageHelper){
		return sqlSessionTemplate.selectList(
				SUBJECT_NS+".getAllSubjectsByCurrentPage", pageHelper);
	}
	
	//전체 반 목록
	public List<HashMap> getAllSubjects(){
		return sqlSessionTemplate.selectList(
				SUBJECT_NS+".getAllSubjects");
	}
	
	
	// 과목 입력
	public int addSubject(Subject subject){
		return sqlSessionTemplate.insert(
				SUBJECT_NS+".addSubject", subject);
	}
	

}









